#include "cvsession.h"

CVSession *CVSession::instance = NULL;
CVSession::CVSession()
{
    network = new CVNetwork();
    sessionId = "";
}

CVSession::~CVSession()
{
    delete network;
}

CVSession *CVSession::get()
{
    if (!instance)
    {
        instance = new CVSession();
    }
    return instance;
}

void CVSession::setCurrentNetwork(CVNetwork *network)
{
    this->network = network;
}

void CVSession::setUser(CVUser *user)
{
    this->user = user;
}

void CVSession::setUserId(const QString &userId)
{
    this->userId = userId;
}

void CVSession::setPassword(const QString &password)
{
    this->password = password;
}

void CVSession::setSessionId(const QString &sessionId)
{
    this->sessionId = sessionId;
}

void CVSession::setCookies(QList<QNetworkCookie> cookies)
{
    this->cookies = cookies;
}

CVNetwork *CVSession::getCurrentNetwork()
{
    return network;
}

CVUser *CVSession::getUser()
{
    return this->user;
}

QString CVSession::getUserId()
{
    return this->userId;
}

QString CVSession::getPassword()
{
    return this->password;
}

QString CVSession::getSessionId()
{
    return this->sessionId;
}

QList<QNetworkCookie> CVSession::getCookies()
{
    return this->cookies;
}

void CVSession::clear()
{
    instance = NULL;
}
